home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Essentials
/
C++ A'Link Files
/
Mar 91
/
CPlus.Dev$ 3⁄1⁄91
/
0281-PascalObject Initial-Feb91
< prev
next >
Wrap
Text File
|
1991-04-01
|
2KB
|
57 lines
Item 1272592 25-Feb-91 15:22PST
From: CPLUS.BUGS MPW C++ Bug Report Handler
To: CPLUS.APPLE$ C++ Interest List--Apple Employees
CPLUS.DEV$ C++ Interest List--Developers
Item forwarded by VIOLET.R to AITKEN.K
------------------------------------------------------------------------------
Sub: PascalObject Initialization
There are certain scenarios in which CFront will not properly initialize the
method dispatch by failing to call '_PGM' from the programs 'main'. This only
happens under the following circumstances:
• The code for main does not call any method belonging to a type derived from
PascalObject, AND is in a compilation unit that has no code appearing before it
that calls any method from a type derived from PascalObject.
Unfortunately merely including a call to operator new (i.e. instantiating an
object) will not automatically trigger this since if the type in question has a
constructor then operator new is actually called inside of the constructor. If
you find yourself this situation where for example your 'main' simply calls
some other routine which uses PascalObject methods then I suggest making an
empty type -> class foo : public PascalObject { } . And including in your
'main' something like -> foo* afoo = new foo; . Since there is no constructor
the compiler will see the call to operator new and include the call to _PGM.
Example of code that will not properly include the call to _PGM:
===============================================================================
class foo : PascalObject {
public:
foo(void);
virtual void meth1(void);
};
void non_member_func(foo* theClass);
void main()
{
foo* afoo = new foo;
non_member_func(afoo);
}
foo::foo(void) { ; }
void foo::meth1(void) { ; }
// NOTE THE CODE THAT INVOKES THE METHOD COMES AFTER CODE FOR MAIN
void non_member_func(foo* theClass)
{
theClass->meth1();
}